// Based on a circular buffer example from http://en.wikipedia.org/wiki/Circular_buffer

/* Opaque buffer element type.  This would be defined by the application. */
typedef struct {
	char *array;
	int size;
} ElemType;

/* Circular buffer object */
typedef struct {
	int size; // maximum number of elements
	int start; // index of oldest element
	int end; // index at which to write new element
	ElemType *elems; // vector of elements
} CircularBuffer;

void cbInit(CircularBuffer *, int);

int cbFree(CircularBuffer *);

int cbIsFull(CircularBuffer *);

int cbIsEmpty(CircularBuffer *);

void cbWrite(CircularBuffer *, ElemType *);

void cbRead(CircularBuffer *, ElemType *);
